package com.huawei.chengdu.meetingdemo.util;

import com.device.idea.meeting.CallCtrl.model.CallTime;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

public class CallTimeUtils {
    private static final int MINUTE_TO_SECOND = 60;
    private static final int HOUR_TO_SECOND = 60 * 60;
    private static final int DAY_TO_SECOND = 60 * 60 * 24;
    private static final int MONTH_TO_SECOND = 60 * 60 * 24 * 30;
    private static final int YEAR_TO_SECOND = 60 * 60 * 24 * 30 * 12;
    private static final SimpleDateFormat TIME_FORMAT = new SimpleDateFormat("yyyyMMddHHmmss", Locale.US);



    public static String callTimeToString(CallTime callTime) {
        return callTime.getYear() + "-" + callTime.getMonth() + "-" +callTime.getDay() + " " +callTime.getHour()
                + ":" + callTime.getMinute();
    }

    public static int callTimeToSecond(CallTime callTime) {
        return callTime.getSecond()
                + callTime.getMinute() * MINUTE_TO_SECOND
                + callTime.getHour() * HOUR_TO_SECOND
                + callTime.getDay() * DAY_TO_SECOND
                + callTime.getMonth() * MONTH_TO_SECOND
                + callTime.getYear() * YEAR_TO_SECOND;
    }

    public static String getCreateTime() {
        return TIME_FORMAT.format(new Date());
    }
}
